﻿ 

using System;

namespace CarTrackr.Business.Validation 
{
    public class  MaximumLengthRule : Rule
    {
        public override RuleType Type
        {
            get
            {
                return RuleType.MaximumLength;
            }
        }


        public int MaximumLength { get; set; }

        public override string Text
        {
            get
            {
                return PropertyName + " should be no more than " + MaximumLength+".";
            }
        }

     
        public override bool Validate(string value)
        {

            if (String.IsNullOrEmpty(value.Trim()))
                return false;


            return value.Length <= MaximumLength;
 
        }

    }
}
